//
//  CCFormWebViewController.m
//  CwinCar
//
//  Created by dlios on 15/10/19.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCFormWebViewController.h"

@interface CCFormWebViewController ()<UIWebViewDelegate>

@end

@implementation CCFormWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.navigationController.navigationBar.hidden = YES;
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,mainScreen_Width , 64)];
    [headView setBackgroundColor:[UIColor colorWithRed:0.088 green:0.331 blue:1.000 alpha:1.000]];
    [self.view addSubview:headView];
    
    UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.542, mainScree_Height / 24.703, mainScreen_Width / 3.75, mainScree_Height / 22.233)];
    [headView addSubview:titleLab];
    [titleLab setText:@"汽 车 详 情"];
    titleLab.textColor = [UIColor whiteColor];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    [headView addSubview:backButton];
    [backButton setFrame:CGRectMake(mainScreen_Width / 22.058, mainScree_Height / 24.703, mainScreen_Width / 12.5, mainScree_Height / 22.233)];
    [backButton setTintColor:[UIColor redColor]];
    [backButton setTitleColor:[UIColor colorWithRed:0.088 green:0.331 blue:1.000 alpha:1.000] forState:UIControlStateSelected];
    
    [self creatWebView];
    
}

-(void)creatWebView
{
    UIWebView *detailWebView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, mainScreen_Width, mainScree_Height - 64)];
    detailWebView.scalesPageToFit = YES;//web自适应屏幕
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webStr]];
    [detailWebView scalesPageToFit];
    [detailWebView loadRequest:request];
    [self.view addSubview:detailWebView];
    detailWebView.delegate = self;
    [self clearWebViewBackground:detailWebView];
}
- (void)backAction:(UIButton *)backBut
{
    self.navigationController.navigationBar.hidden = NO;
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)clearWebViewBackground:(UIWebView *)webView
{
    UIWebView *web = webView;
    for (id v in web.subviews) {
        if ([v isKindOfClass:[UIScrollView class]]) {
            [v setBounces:NO];
        }
    }
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
